import parole
from parole.colornames import colors
from parole.display import interpolateRGB
import pygame, random

import sim, sim_items, main
from util import *

class ScrollDarkness(sim_items.Scroll):
    def __init__(self):
        sim_items.Scroll.__init__(self, "darkness", "?", 
                ('light', 'near', 'less'),
                idDescription="This scroll dissolves into a permanent orb of "\
                    "otherworldly darkness, unnervingly resistant to mundane "\
                    "light sources.")

    def read(self, reader):
        self.map = reader.parentTile.map
        #rgb = random.choice(['White', 'PaleTurquoise', 'Cyan', 'Pink',
        #    'SpringGreen', 'Teal'])
        rgb = (255,255,255)
        self.lightSource = parole.map.LightSource(rgb, -8.0)

        self.lightSource.apply(self.map, reader.pos)
        self.map.update()
        reader.identify(self)

        if main.mapFrame.fovObj and not main.player.dead:
            main.mapFrame.touchFOV()

#        main.schedule.add(sim.Event('stoplight', main.schedule.time + 2*60000,
#            (self,), dests=[self]))

#    def listen(self, event):
#        sim_items.Scroll.listen(self, event)
#
#        if event.id == 'unilluminate' and event.args[0] is self:
#            self.map.setAmbientLight((255,255,255), self.originalIntensity)
#            self.map.update()


#========================================
thingClass = ScrollDarkness

